package com.mdinfo.gw.door.web

import com.mdinfo.base.common.bean.CommonResult
import com.mdinfo.base.common.bean.DataGrid
import com.mdinfo.gw.door.param.*
import com.mdinfo.gw.door.service.IDoorCardService
import com.mdinfo.gw.door.vo.*
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import javax.validation.Valid

/**
 * Created by Administrator on 2018/1/15.
 */
@RestController
@RequestMapping("/sys/doorCard")
class DoorCardController(
        val doorCardService:IDoorCardService
){


    @RequestMapping("/add")
    fun add(@Valid param:DoorCardAddParam):CommonResult<Void>{
        return doorCardService.add(param)
    }

    @RequestMapping("/listQuery")
    fun listQuery(@Valid param: DoorCardListQueryParam)
            :CommonResult<DataGrid<DoorCardListQueryVo>>{

        return doorCardService.listQuery(param)
    }

    @RequestMapping("/modify")
    fun modify(@Valid param: DoorCardModifyParam)
            :CommonResult<Void>{

        return doorCardService.modify(param)
    }

    @RequestMapping("/listUnBindEmp")
    fun listUnBindEmp():CommonResult<List<DoorCardListUnBindEmpVo>>{
        return doorCardService.listUnBindEmp()
    }


    @RequestMapping("/toDel")
    fun toDel(@Valid param: DoorCardToDelParam):CommonResult<Void>{
        return doorCardService.toDel(param)
    }

    @RequestMapping("/bindEmp")
    fun bindEmp(@Valid param: DoorCardBindEmpParam):CommonResult<Void>{
        return doorCardService.bindEmp(param)
    }

    @RequestMapping("/unBindEmp")
    fun unBindEmp(@Valid param: DoorCardUnBindEmpParam)
            :CommonResult<Void>{
        return doorCardService.unBindEmp(param)
    }


    @RequestMapping("/bindDoor")
    fun bindDoor(@Valid param:DoorCardBindDoorParam):CommonResult<Void>{

        return doorCardService.bindDoor(param)
    }

    @RequestMapping("/unBindDoor")
    fun unBindDoor(@Valid param:DoorCardUnBindDoorParam): CommonResult<Void>{
        return doorCardService.unBindDoor(param)
    }

    @RequestMapping("/listAll")
    fun listAll():CommonResult<List<DoorCardListCardVo>>{
        return doorCardService.listAll()
    }

    @RequestMapping("/batchBind")
    fun batchBind(@Valid param:DoorCardBatchBindParam):CommonResult<Void>{
        return doorCardService.batchBind(param)
    }

    @RequestMapping("/listBindTable")
    fun listBindTable(@Valid param:DoorCardListBindTableParam)
            :CommonResult<DataGrid<DoorCardListBindTableVo>>{
        return doorCardService.listBindTable(param)
    }

    @RequestMapping("/batchUnBind")
    fun batchUnBind(@Valid param :DoorCardBatchUnBindParam)
            :CommonResult<Void>{
        return doorCardService.batchUnBind(param)
    }

    @RequestMapping("/listByDoorId")
    fun listByDoorId(@Valid param:DoorCardListByDoorIdParam)
            :CommonResult<DataGrid<DoorCardListByDoorIdVo>>{
        return doorCardService.listByDoorId(param)
    }

    /**根据开放时间id查询绑定的门卡*/
    @RequestMapping("/listByTimeId")
    fun listByTimeId(@Valid param: DoorCardListByTimeIdParam)
            :CommonResult<DataGrid<DoorCardListByTimeIdVo>>{
        return doorCardService.listByTimeId(param)
    }
}